package com.cohen.playerobject;

import java.util.Scanner;

public class main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner input = new Scanner ( System.in );
		player Player1 = new player();
		boolean playerClassNotValid = true;
		boolean playerRaceNotValid = true;
		System.out.println("Input desired player name.");
		boolean reroll;
		boolean realSpecialization;
		Player1.setName(input.next());
		System.out.println("Input desired player race (elf, human, or dwarf).\nElves have +2 Cunning\nHumans have +2 Stamina \nDwarves have +2 Spirit");
		//loop to ensure valid race
		do{
			Player1.setRace(input.next());
			if (Player1.getRace().equalsIgnoreCase("elf") || Player1.getRace().equalsIgnoreCase("human") || Player1.getRace().equalsIgnoreCase("dwarf")){
				playerRaceNotValid = false;
			} else {
				System.out.println("Chosen race not valid. \nIt's not your fault, it's ancestors were probably all killed in a mass extinction never mentioned in the game's plot.\nIn any case, please pick either elf, human, or dwarf.");
			}
		} while (playerRaceNotValid == true);
		System.out.println("Input desired player class (rouge, mage, or warrior).");
		//loop to ensure valid class
		do{
			Player1.setClass(input.next());
			if (Player1.getclass().equalsIgnoreCase("warrior") || Player1.getclass().equalsIgnoreCase("rogue") || Player1.getclass().equalsIgnoreCase("mage")){
				playerClassNotValid = false;
			} else {
				System.out.println("Chosen class not valid.\nPlease pick either warrior, rouge, or mage.");
			}
		} while (playerClassNotValid == true);
		do{
			//Arbitrary "general" stats are assigned aselectively so they can be up here
			Player1.setCharisma(player.assignGeneralAttribute());
			Player1.setLuck(player.assignGeneralAttribute());
			Player1.setPerception(player.assignGeneralAttribute());
			//Apply stats
			if (Player1.getclass().equalsIgnoreCase("mage")){
				//Assigns mage stats
				Player1.setIntelligence(player.assignPrimaryAttribute());
				Player1.setCunning(player.assignSecondaryAttribute());
				Player1.setSpirit(player.assignSecondaryAttribute());

				Player1.setAgility(player.assignGeneralAttribute());
				Player1.setStamina(player.assignGeneralAttribute());
				Player1.setStrength(player.assignGeneralAttribute());
			} else if (Player1.getclass().equalsIgnoreCase("rouge")){
				//Assigns rouge stats
				Player1.setAgility(player.assignPrimaryAttribute());
				Player1.setCunning(player.assignSecondaryAttribute());
				Player1.setStamina(player.assignSecondaryAttribute());

				Player1.setIntelligence(player.assignGeneralAttribute());
				Player1.setStrength(player.assignGeneralAttribute());
				Player1.setSpirit(player.assignGeneralAttribute());
			} else {
				//Assigns warrior stats
				Player1.setStrength(player.assignPrimaryAttribute());
				Player1.setStamina(player.assignSecondaryAttribute());
				Player1.setSpirit(player.assignSecondaryAttribute());

				Player1.setIntelligence(player.assignGeneralAttribute());
				Player1.setAgility(player.assignGeneralAttribute());
				Player1.setCunning(player.assignGeneralAttribute());
			}
			System.out.println("Your inteligence is " + Player1.getIntelligence());
			System.out.println("Your Agility is " + Player1.getAgility());
			System.out.println("Your Strength is " + Player1.getStrength());
			System.out.println("Your Cunning is " + Player1.getCunning());
			System.out.println("Your Spirit is " + Player1.getSpirit());
			System.out.println("Your Stamia is " + Player1.getStamina());
			System.out.println("Your Luck is " + Player1.getLuck());
			System.out.println("Your Perception is " + Player1.getPerception());
			System.out.println("Your Charisma is " + Player1.getCharisma());
			if (Player1.getRace().equals("elf")){
				Player1.setCunning((Player1.getCunning() + 2));
			} else if (Player1.getRace().equals("human")){
				Player1.setStamina((Player1.getStamina() + 2));
			}else {
				Player1.setCunning((Player1.getSpirit() + 2));
			}

			if (Player1.getclass().equalsIgnoreCase("mage")){
				System.out.println("As a mage, your primary stat is Intelligence (" + Player1.getIntelligence() + "), and your secondary stats are Cunning (" + Player1.getCunning() + ") and Spirit (" + Player1.getSpirit() + ").");
			} else if (Player1.getclass().equalsIgnoreCase("rogue")){
				System.out.println("As a rogue, your primary stat is Agility (" + Player1.getAgility() + "), and your secondary stats are Cunning (" + Player1.getCunning() + ") and Stamina (" + Player1.getStamina() + ").");
			} else {
				System.out.println("As a warrior, your primary stat is Strength (" + Player1.getStrength() + "), and your secondary stats are Stamina (" + Player1.getStamina() + ") and Spirit (" + Player1.getSpirit() + ").");
			}
			System.out.println("Do you wish to reroll? true/false");
			reroll = input.nextBoolean();
		} while (reroll == true);
		System.out.println("Each ability specialisation offers five abilities/passives.\nAs a " + Player1.getclass() + ", the specializations you have availible are:");
		for (int i = 0; i <= 7; i++){
			System.out.print(Player1.generateSpecializations(i, Player1.getclass()) + ", ");
		}
		System.out.print("and " + Player1.generateSpecializations(8, Player1.getclass()) + ".");
		System.out.println("\nPlease input five on separate lines.");
		//Line below resolves issue with for loop where the first specialization was not being added
		Player1.setSpecialization(input.nextLine(), 0);
		for (int i = 0; i < 5; i++){
			do {
				Player1.setSpecialization(input.nextLine(), i);
				if (Player1.getSpecialization(i).equals(Player1.generateSpecializations(0, Player1.getclass())) || Player1.getSpecialization(i).equals(Player1.generateSpecializations(1, Player1.getclass())) || Player1.getSpecialization(i).equals(Player1.generateSpecializations(2, Player1.getclass())) || Player1.getSpecialization(i).equals(Player1.generateSpecializations(3, Player1.getclass())) || Player1.getSpecialization(i).equals(Player1.generateSpecializations(4, Player1.getclass())) || Player1.getSpecialization(i).equals(Player1.generateSpecializations(5, Player1.getclass())) || Player1.getSpecialization(i).equals(Player1.generateSpecializations(6, Player1.getclass())) || Player1.getSpecialization(i).equals(Player1.generateSpecializations(7, Player1.getclass())) || Player1.getSpecialization(i).equals(Player1.generateSpecializations(8, Player1.getclass()))){
					realSpecialization = true;
				} else {
					realSpecialization = false;
					System.out.println("Invalid specialiazation. Please refer to the list above.");
				}
			} while (realSpecialization == false);
			//System.out.println("Specialization " + i + " = " + Player1.getSpecialization(i));	
		}

	}

}
